package com.zc.demo.service;

import com.zc.demo.dao.BookDao;
import com.zc.demo.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.awt.print.Book;
import java.util.List;

//@Component
@Service
public class BookService {
//    private BookDao bookDao = new BookDao();

    @Autowired
    private BookDao bookDao;
    public List<BookInfo> getBookList(){
//        BookDao bookDao = new BookDao();
        //先获取数据库中的书籍信息，此处先造假数据
        List<BookInfo> books = bookDao.mockData();
        //处理一下展示细节
        for(BookInfo book:books){
            if(book.getBook_status() == 1){
                book.setBook_status_CN("可借阅");
            }else {
                book.setBook_status_CN("不可借阅");
            }
        }
        return books;
    }
}
